package controller

import (
	"gitee.com/csingo/cConfig"
	"gitee.com/csingo/cError"
	"gitee.com/csingo/cResponse"
	"github.com/gin-gonic/gin"
)

type HelloController struct{}

func (i *HelloController) ControllerName() (app, name string) {
	return "demo", "HelloController"
}

func (i *HelloController) Say(ctx *gin.Context) (int, interface{}) {
	return cResponse.Api(ctx, "Hello world", nil)
}

func (i *HelloController) Ping(ctx *gin.Context) (int, interface{}) {
	return cResponse.Api(ctx, "pong", nil)
}

func (i *HelloController) Error(ctx *gin.Context) (int, interface{}) {
	return cResponse.Api(ctx, nil, cError.CError_Csingo_System)
}

func (i *HelloController) Config(ctx *gin.Context) (int, interface{}) {
	name := ctx.Query("name")
	rsp, err := cConfig.GetConf(name)
	return cResponse.Api(ctx, rsp, err)
}
